Add SwitchBot Standing Fan (FAN2) support#459
Open
fankai777 wants to merge 5 commits intosblibs:masterfrom
Open
Add SwitchBot Standing Fan (FAN2) support#459fankai777 wants to merge 5 commits intosblibs:masterfrom
fankai777 wants to merge 5 commits intosblibs:masterfrom
Conversation
- Add SwitchbotStandingFan device class with 5 preset modes - Support independent horizontal/vertical oscillation control with angle selection - Add night light control (off/level_1/level_2) - Register Standing Fan BLE advertisement IDs - Add unit tests for fan instantiation and on/off Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Test all 5 preset modes including custom_natural - Test get_basic_info parsing with mode=5 (custom_natural) and oscillation bits - Test horizontal/vertical oscillation angle setting (30/60/90) - Test night light control (off/level_1/level_2) - Test independent horizontal/vertical oscillation commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Cover the False branches of set_horizontal_oscillation and set_vertical_oscillation, and add tests for the state getter methods.
There was a problem hiding this comment.
Pull request overview
Adds BLE support for the SwitchBot Standing Fan (FAN2) by extending the existing fan device implementation and wiring the new model into advertisement parsing and public exports.
Changes:
- Introduces
SwitchbotStandingFanwith standing-fan-specific preset modes plus controls for oscillation angles and night light. - Extends fan basic-info parsing to expose horizontal/vertical oscillation flags.
- Registers Standing Fan model identifiers in the BLE advertisement parser and adds unit tests for the new functionality.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
switchbot/devices/fan.py |
Adds standing fan device class + new oscillation primitives and updates basic-info parsing. |
switchbot/const/fan.py |
Adds StandingFanMode enum. |
switchbot/const/__init__.py |
Exposes StandingFanMode and adds STANDING_FAN to SwitchbotModel. |
switchbot/adv_parser.py |
Registers Standing Fan advertisement IDs to be parsed as a fan device. |
switchbot/__init__.py |
Exports StandingFanMode and SwitchbotStandingFan at the package level. |
tests/test_fan.py |
Adds unit tests covering standing fan behaviors and command formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+19
to
+24
| COMMAND_START_OSCILLATION = f"{COMMAND_HEAD}02010101" # H+V start | ||
| COMMAND_STOP_OSCILLATION = f"{COMMAND_HEAD}02010202" # H+V stop | ||
| COMMAND_START_HORIZONTAL_OSCILLATION = f"{COMMAND_HEAD}020101ff" # H start, V keep | ||
| COMMAND_STOP_HORIZONTAL_OSCILLATION = f"{COMMAND_HEAD}020102ff" # H stop, V keep | ||
| COMMAND_START_VERTICAL_OSCILLATION = f"{COMMAND_HEAD}0201ff01" # H keep, V start | ||
| COMMAND_STOP_VERTICAL_OSCILLATION = f"{COMMAND_HEAD}0201ff02" # H keep, V stop |
Comment on lines
90
to
95
| @update_after_operation | ||
| async def set_oscillation(self, oscillating: bool) -> bool: | ||
| """Send command to set fan oscillation""" | ||
| if oscillating: | ||
| return await self._send_command(COMMAND_START_OSCILLATION) | ||
| return await self._send_command(COMMAND_STOP_OSCILLATION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add full BLE control support for the SwitchBot Standing Fan (model FAN2), extending the existing Circulator Fan implementation.
Changes
Features
SwitchbotStandingFaninherits fromSwitchbotFan, reusing on/off, speed, and oscillation controls.normal,natural,sleep,baby,custom_natural(viaStandingFanModeenum).set_horizontal_oscillation_angle()/set_vertical_oscillation_angle()for angle selection (30°/60°/90°).set_night_light()control with 3 states: off, level_1, level_2.Parser
adv_parser.py: Registered Standing Fan BLE advertisement IDs (\x00\x11\x07\x60,\x01\x11\x07\x60).SwitchbotStandingFan.get_basic_info(): Parses battery, on/off, horizontal/vertical oscillation, mode (1-5), speed, firmware from BLE response.Tests
custom_natural)get_basic_infoparsing with oscillation bits and mode=5